package com.shrct.businessprocess.project.impl;

import com.shrct.businessprocess.project.RCCustomerContractMoneyAccept;
import com.shrct.businessprocess.project.RCCustomerContractMoneyAcceptAssignment;
import com.shrct.businessprocess.project.RCRealMoney;
import com.shrct.businessprocess.project.impl.RCCustomerContractMoneyAcceptImpl;
import com.shrct.businessprocess.project.proxy.RCCustomerContractMoneyAcceptAssignmentProxy;
import com.shrct.businessprocess.purchase.RCPurchaseIncomeRequest;
import com.shrct.businessprocess.purchase.impl.RCPurchaseIncomeRequestImpl;
import edu.fudan.mylang.pf.BaseModelObject;
import edu.fudan.mylang.pf.IObjectFactory;
import javax.persistence.AssociationOverride;
import javax.persistence.AssociationOverrides;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.hibernate.annotations.DiscriminatorOptions;

@Entity
@DiscriminatorValue("RCCUSTOMERCONTRACTMONEYACCEPTASSIGNMENT_TYPE")
@DiscriminatorOptions(force = true)
@DiscriminatorColumn(length = 64)
@Table(name = "rccustomercontractmoneyacceptassignment")
public class RCCustomerContractMoneyAcceptAssignmentImpl extends BaseModelObject implements RCCustomerContractMoneyAcceptAssignment {
  public RCCustomerContractMoneyAcceptAssignmentImpl() {
    super();
  }
  
  public RCCustomerContractMoneyAcceptAssignmentImpl(final RCCustomerContractMoneyAccept accept) {
    super();
    this.accept = accept;
  }
  
  @JoinColumn(name = "accept_id")
  @ManyToOne(targetEntity = RCCustomerContractMoneyAcceptImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCCustomerContractMoneyAccept accept;
  
  public RCCustomerContractMoneyAccept getAccept() {
    return this.accept;
  }
  
  public RCCustomerContractMoneyAcceptAssignment setAccept(final RCCustomerContractMoneyAccept accept) {
    this.accept = accept;
    return this;			
    
  }
  
  @JoinColumn(name = "income_id")
  @ManyToOne(targetEntity = RCPurchaseIncomeRequestImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCPurchaseIncomeRequest income;
  
  public RCPurchaseIncomeRequest getIncome() {
    return this.income;
  }
  
  public RCCustomerContractMoneyAcceptAssignment setIncome(final RCPurchaseIncomeRequest income) {
    this.income = income;
    return this;			
    
  }
  
  @Embedded
  @AttributeOverrides(value = { @AttributeOverride(name = "amount", column = @Column(name = "amount_amount") ), @AttributeOverride(name = "exchangeRate", column = @Column(name = "amount_exchangeRate") ), @AttributeOverride(name = "workaround", column = @Column(name = "amount_workaround") ) } )
  @AssociationOverrides(value = @AssociationOverride(name = "currencyType", joinColumns = @JoinColumn(name = "amount_currencyType") ) )
  private RCRealMoney amount = com.shrct.businessprocess.project.RCRealMoney.create();
  
  public RCRealMoney getAmount() {
    return this.amount;
  }
  
  public RCCustomerContractMoneyAcceptAssignment setAmount(final RCRealMoney amount) {
    this.amount = amount;
    return this;			
    
  }
  
  public static RCCustomerContractMoneyAcceptAssignment create(final RCCustomerContractMoneyAccept accept, final IObjectFactory objectFactory) {
    com.shrct.businessprocess.project.RCCustomerContractMoneyAcceptAssignment rCCustomerContractMoneyAcceptAssignment = new com.shrct.businessprocess.project.impl.RCCustomerContractMoneyAcceptAssignmentImpl(
    	accept
    );
    objectFactory.create(rCCustomerContractMoneyAcceptAssignment);
    return rCCustomerContractMoneyAcceptAssignment;			
    
  }
  
  public static RCCustomerContractMoneyAcceptAssignment createRCCustomerContractMoneyAcceptAssignmentImpl(final RCCustomerContractMoneyAccept accept, final IObjectFactory objectFactory, final Procedure1<RCCustomerContractMoneyAcceptAssignment> init) {
    com.shrct.businessprocess.project.RCCustomerContractMoneyAcceptAssignment rCCustomerContractMoneyAcceptAssignment = new com.shrct.businessprocess.project.impl.RCCustomerContractMoneyAcceptAssignmentImpl(
    	accept
    );
    objectFactory.create(rCCustomerContractMoneyAcceptAssignment);
    init.apply(rCCustomerContractMoneyAcceptAssignment);
    
    return rCCustomerContractMoneyAcceptAssignment;			
    
  }
  
  public RCCustomerContractMoneyAcceptAssignmentProxy toProxy() {
    com.shrct.businessprocess.project.proxy.RCCustomerContractMoneyAcceptAssignmentProxy proxy = new com.shrct.businessprocess.project.proxy.RCCustomerContractMoneyAcceptAssignmentProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
